﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WorkTime.Refresh.Logical;

namespace WorkTime.Refresh.UI
{
    /// <summary>
    /// Interaction logic for Configuration.xaml
    /// </summary>
    public partial class Configuration : Window
    {
        private WorkTimeDataContext wtDB = null;

        public Configuration()
        {
            InitializeComponent();
            wtDB = new WorkTimeDataContext();
        }

        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            
        }

        private void MenuItemClose_Click(object sender, RoutedEventArgs e)
        {
            e.Handled = true;
            Application.Current.Shutdown();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            var all = from emp in wtDB.Employees select emp;
            allEmployeeView.ItemsSource = all.ToList<Employee>();
        }

        #region dragMgr_ProcessDrop

        // Performs custom drop logic for the top ListView.
        //void dragMgr_ProcessDrop(object sender, ProcessDropEventArgs<Task> e)
        //{
        //    // This shows how to customize the behavior of a drop.
        //    // Here we perform a swap, instead of just moving the dropped item.

        //    //int higherIdx = Math.Max(e.OldIndex, e.NewIndex);
        //    //int lowerIdx = Math.Min(e.OldIndex, e.NewIndex);

        //    //if (lowerIdx < 0)
        //    //{
        //    //    // The item came from the lower ListView
        //    //    // so just insert it.
        //    //    e.ItemsSource.Insert(higherIdx, e.DataItem);
        //    //}
        //    //else
        //    //{
        //    //    // null values will cause an error when calling Move.
        //    //    // It looks like a bug in ObservableCollection to me.
        //    //    if (e.ItemsSource[lowerIdx] == null ||
        //    //        e.ItemsSource[higherIdx] == null)
        //    //        return;

        //    //    // The item came from the ListView into which
        //    //    // it was dropped, so swap it with the item
        //    //    // at the target index.
        //    //    e.ItemsSource.Move(lowerIdx, higherIdx);
        //    //    e.ItemsSource.Move(higherIdx - 1, lowerIdx);
        //    //}

        //    //// Set this to 'Move' so that the OnListViewDrop knows to 
        //    //// remove the item from the other ListView.
        //    //e.Effects = DragDropEffects.Move;
        //}

        #endregion // dragMgr_ProcessDrop

        #region OnListViewDragEnter

        // Handles the DragEnter event for both ListViews.
        void OnListViewDragEnter(object sender, DragEventArgs e)
        {
            e.Effects = DragDropEffects.Move;
        }

        #endregion // OnListViewDragEnter

        #region OnListViewDrop

        // Handles the Drop event for both ListViews.
        void OnListViewDrop(object sender, DragEventArgs e)
        {
            //if (e.Effects == DragDropEffects.None)
            //    return;

            //Task task = e.Data.GetData(typeof(Task)) as Task;
            //if (sender == this.listView)
            //{
            //    if (this.dragMgr.IsDragInProgress)
            //        return;

            //    // An item was dragged from the bottom ListView into the top ListView
            //    // so remove that item from the bottom ListView.
            //    (this.listView2.ItemsSource as ObservableCollection<Task>).Remove(task);
            //}
            //else
            //{
            //    if (this.dragMgr2.IsDragInProgress)
            //        return;

            //    // An item was dragged from the top ListView into the bottom ListView
            //    // so remove that item from the top ListView.
            //    (this.listView.ItemsSource as ObservableCollection<Task>).Remove(task);
            //}
        }

        #endregion // OnListViewDrop


    }
}
